package com.zking.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;

public class JDBCUtil {
	private static String url,user,password;
	static{
		try {
			Properties p=new Properties();
			p.load(JDBCUtil.class.getResourceAsStream("/peizhi.properties"));
			Class.forName(p.getProperty("jdbc.driverName","com.mysql.jdbc.Driver"));
			url=p.getProperty("jdbc.url");
			user=p.getProperty("jdbc.user");
			password=p.getProperty("jdbc.password");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	private JDBCUtil(){}
	public static Connection getConnection() throws SQLException{
		return DriverManager.getConnection(url, user, password);
	}
	public static void close(ResultSet rs){
		try {
			rs.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
